set_source_files_properties(
    dynamic_add_float16_v51.cce
    dynamic_add_float32_v51.cce
    dynamic_add_int32_v51.cce
    dynamic_maximum_float16_v51.cce
    dynamic_maximum_float32_v51.cce
    dynamic_maximum_int32_v51.cce
    dynamic_minimum_float16_v51.cce
    dynamic_minimum_float32_v51.cce
    dynamic_minimum_int32_v51.cce
    dynamic_mul_float16_v51.cce
    dynamic_mul_float32_v51.cce
    dynamic_mul_int32_v51.cce
    add_Ascend310P3_int8_210000000.cce
    add_Ascend310P3_int8_210010000.cce
    add_Ascend310P3_int8_223000000.cce
    add_Ascend310P3_int8_232000000.cce
    mul_Ascend310P3_int8_210000000.cce
    mul_Ascend310P3_int8_210010000.cce
    mul_Ascend310P3_int8_223000000.cce
    mul_Ascend310P3_int8_232000000.cce
    maximum_Ascend310P3_int8_210000000.cce
    maximum_Ascend310P3_int8_210010000.cce
    maximum_Ascend310P3_int8_223000000.cce
    maximum_Ascend310P3_int8_232000000.cce
    minimum_Ascend310P3_int8_210000000.cce
    minimum_Ascend310P3_int8_210010000.cce
    minimum_Ascend310P3_int8_223000000.cce
    minimum_Ascend310P3_int8_232000000.cce
    MemSet_dynamic_AtomicAddrClean_1_ascend310p3.cce
    te_gatherv2_ca87d1f41c037f24ece7993bc5c6f9afc00be851bcbaef7c03daf96701a30810_1.cce
    te_gatherv2_ec8c036da6e525f834dabb7a436b50387bbc5929f5201b28f0db7bd63fdb3a9b_1.cce
    te_unsortedsegmentsum_d0a8c7e68142042963e855ce6004fa68d52228200ba7cf5426e5ab47e86ae38c_1.cce PROPERTIES LANGUAGE CXX
)

set_source_files_properties(te_gatherv2_ec8c036da6e525f834dabb7a436b50387bbc5929f5201b28f0db7bd63fdb3a9b_1.cce
    PROPERTIES
    COMPILE_FLAGS
    "-mllvm -cce-aicore-jump-expand=true"
)

add_library(hccl_reduce_op_Ascend310P3_obj
    OBJECT dynamic_add_float16_v51.cce
           dynamic_add_float32_v51.cce
           dynamic_add_int32_v51.cce
           dynamic_maximum_float16_v51.cce
           dynamic_maximum_float32_v51.cce
           dynamic_maximum_int32_v51.cce
           dynamic_minimum_float16_v51.cce
           dynamic_minimum_float32_v51.cce
           dynamic_minimum_int32_v51.cce
           dynamic_mul_float16_v51.cce
           dynamic_mul_float32_v51.cce
           dynamic_mul_int32_v51.cce
           add_Ascend310P3_int8_210000000.cce
           add_Ascend310P3_int8_210010000.cce
           add_Ascend310P3_int8_223000000.cce
           add_Ascend310P3_int8_232000000.cce
           mul_Ascend310P3_int8_210000000.cce
           mul_Ascend310P3_int8_210010000.cce
           mul_Ascend310P3_int8_223000000.cce
           mul_Ascend310P3_int8_232000000.cce
           maximum_Ascend310P3_int8_210000000.cce
           maximum_Ascend310P3_int8_210010000.cce
           maximum_Ascend310P3_int8_223000000.cce
           maximum_Ascend310P3_int8_232000000.cce
           minimum_Ascend310P3_int8_210000000.cce
           minimum_Ascend310P3_int8_210010000.cce
           minimum_Ascend310P3_int8_223000000.cce
           minimum_Ascend310P3_int8_232000000.cce
           MemSet_dynamic_AtomicAddrClean_1_ascend310p3.cce
           te_gatherv2_ca87d1f41c037f24ece7993bc5c6f9afc00be851bcbaef7c03daf96701a30810_1.cce
           te_gatherv2_ec8c036da6e525f834dabb7a436b50387bbc5929f5201b28f0db7bd63fdb3a9b_1.cce
           te_unsortedsegmentsum_d0a8c7e68142042963e855ce6004fa68d52228200ba7cf5426e5ab47e86ae38c_1.cce
)

target_compile_options(hccl_reduce_op_Ascend310P3_obj PRIVATE
    -c
    -O2
    --cce-aicore-arch=dav-m200
    --cce-aicore-only
    -Wl,z,now
    -fPIE -pie
    -z now
    -fstack-protector-all
    -mllvm -cce-aicore-mask-opt=false
)

get_filename_component(CCE_DIR "${CMAKE_LINKER}" PATH)

#string(REPLACE "," " " hccl_reduce_op_obj "$<TARGET_OBJECTS:hccl_reduce_op_obj>")

add_custom_target(hccl_reduce_op_Ascend310P3
    COMMAND ${CCE_DIR}/ld.lld -m aicorelinux -Ttext 0 $<TARGET_OBJECTS:hccl_reduce_op_Ascend310P3_obj> -o ${CMAKE_CURRENT_BINARY_DIR}/hccl_reduce_op_Ascend310P3.o
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    COMMAND_EXPAND_LISTS
)
add_dependencies(hccl_reduce_op_Ascend310P3 hccl_reduce_op_Ascend310P3_obj)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hccl_reduce_op_Ascend310P3.o OPTIONAL
    DESTINATION ${INSTALL_LIBRARY_DIR}
)